<script>
    function LTrim(value) {
        var re = /\s*((\S+\s*)*)/;
        return value.replace(re, "$1");
    }

    function RTrim(value) {
        var re = /((\s*\S+)*)\s*/;
        return value.replace(re, "$1");
    }

    function trim(value) {
        return LTrim(RTrim(value));
    }
    function load() {
        alert("load event detected!");
      }
    function checkComment(){
        var countError  = 0;
        var content       = trim(document.getElementById('textarea_full').value);
        var reg = /^[a-zA-ZÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚĂĐĨŨƠàáâãèéêìíòóôõùúăđĩũơƯĂẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼỀỀỂưăạảấầẩẫậắằẳẵặẹẻẽếềểỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪễệỉịọỏốồổỗộớờởỡợụủứừỬỮỰỲỴÝỶỸửữựỳỵỷỹ ]+$/;
            if(reg.test(content) === false)
            {
                document.getElementById("errcontent").innerHTML= "<span class='msg_err' > Bạn chưa nhập lời bình!.</span>";
                countError++;
            }
            elseif(countError > 0)
            {
                return false;
            }
            else
            {
                return true;
            }
    }
    
</script>

<div class="widget">
    <h3 style="text-align: left">Chi tiết tour</h3>
    
    <?php
        $place = new Default_Model_Place();
        $common = new Default_Model_Common();
        $start_date = strtotime($this->tour['start_date']);
        $finish_date = strtotime($this->tour['finish_date']);
    ?>
    
    <div class="news_content">
        <div class="news_left">
                <div class="news_lists">
                   <div class="news_images">
                        <img src="<?php echo $this->baseUrl('/public/img/tour/') . $this->tour['tour_image']; ?>" />
                    </div>
                   <p style="text-align: justify;line-height: 1.8;">
                    <div class="news_titles" >
                        <p><span style="font-weight: bold; font-size: 18px;"><?php echo $this->tour['tour_name']; ?></span></p>
                        <p>Nơi bắt đầu: <?php echo $place->getPlaceNameById($this->tour['start_place']); ?></p>
                        <p>Nơi kết thúc: <?php echo $place->getPlaceNameById($this->tour['finish_place']); ?></p>
                        <p>Ngày đi: <?php echo date('d/m/Y', $start_date); ?></p>
                        <p>Ngày về: <?php echo date('d/m/Y', $finish_date); ?></p>
                        <p>Giá vé người lớn: <?php echo $common->formatMoney($this->tour['adult_price']); ?> VNĐ</p>
                        <p>Giá vé trẻ em: <?php echo $common->formatMoney($this->tour['children_price']); ?> VNĐ</p>
                        <br />
                        <a href="<?php echo $this->baseUrl('tour/book?tour_id=') . $this->tour['tour_id'] ?>">
                            <img src="<?php echo $this->baseUrl('public/templates/default/images/booktour.jpg'); ?>" />
                        </a>
                    </div>
                     <div class="news_plaintexts" style="clear: both;">
                         <?php echo $this->tour['description']; ?>   
                    </div>
                    </p>
                </div>
                <div style="clear: both;"></div>
            <div class="news_comment">
                <h3 class="h3_comment">Bình luận tour --&gt;&gt; <span style="font-style: normal;font-weight:bold;margin-bottom:5px;">
                <?php $content = preg_replace('/\s+/', ' ', $this->news_title);
                $common = new Default_Model_Common();
                          echo $common->cut_string($content, 55, 1); ?> 
                </span><span style="font-style: normal;" > (Có <?php echo count($this->data) ?> bình luận)</span></h3>
                <?php
                    if(count($this->data) > 0) :
                        foreach($this->data as $value) : ?>
                        <div class="news_list_comment">
                            <table >
                                <tr>
                                    <td  width="90px">
                
                                        <?php if($value["avatar"]!=''): ?>
                                            <img class="img_avatar" width="60px" height="50px" src="<?php echo $this->baseUrl('/public/img/user/'.$value["avatar"]) ?>"/>
                                        <?php else:?>                       
                                            <img class="img_avatar" width="60px" height="50px" src="<?php echo $this->baseUrl('/public/img/user/default.jpg') ?>"/>
                                        <?php endif;  ?>
                 
                                    </td>
                                    <td>
                                        <div class="news_main_comment">
                                        <span style="font-weight: bold;color: #135f68;"><?php echo $value['fullname'] ?>:</span> <?php echo $value['term'] ?>
                                    
                                        <div style="width:550px;color:#1e6e75;text-align:right;"><p style="font-style: italic;" align="right"><h5><u>Ngày đăng: 
                                        <?php $sqldate = strtotime($value['create_date']);
                                            $create_date = date('d/m/Y H:i', $sqldate);
                                            echo $create_date; ?></u></h5>
                                        </p>
                                        </div>
                                   
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                </tr>
                            </table>
                        </div>
                    <?php endforeach; ?>
                    
                    <div style="clear: both;"></div>
                <?php endif; ?>
                <?php
                $auth = Zend_Auth::getInstance();
                    if($auth->hasIdentity()) : ?>
                <form action="" method="post" onsubmit="return checkComment();" >
                    <table>
                        <tr>
                            <td>
                            <div class="text_comment">
                            <textarea name="content" cols="78" rows="4" id="textarea_full">
                                
                            </textarea> 
                            <input class="button_comment" type="submit" name="submit" value="Gửi bình luận"/>
                            </div>
                            </td>
                        </tr>
                        <tr ><td id="errcontent" class="msg_error"><?php echo $this ->errorcontent; ?></td ></tr>
                    </table>
                </form>
                <?php else : ?>
                <h4 class="msg_error">Bạn chưa đăng nhập, hãy đăng nhập để bình luận tin tức này <br></h4>
                <?php endif; ?>
            </div>
        </div>
        
        <div class="news_right">
            <?php
            if(count($this->recommend) > 0) :
                foreach($this->recommend as $value) : 
            ?>
            <div class="news_list_right">
                <div class="news_image_right">
                    <a  href="<?php echo $this->baseUrl('tour/details?tour_id=') . $value['tour_id']; ?>">

                    <img src="<?php echo $this->baseUrl('/public/img/tour/') . $value['tour_image']; ?>" />
                    </a>
                </div>
                
                <div class="news_main_right">
                    <a  href="<?php echo $this->baseUrl('tour/details?tour_id=') . $value['tour_id']; ?>">
                        <?php echo $value['tour_name']; ?>
                    </a><br />
                    
                    <p style="font-size: 12px;color:#00aeea">Ngày đăng: 
                        <?php $sqldate = strtotime($value['create_date']);
                            $create_date = date('d/m/Y', $sqldate);
                            echo $create_date; ?>
                    </p>
                </div>
            </div>
            <?php endforeach; ?>
        <?php endif; ?>
        </div>
        
    </div>
    
</div>
